package projectmanagement.models;

import java.util.*;

/**
 * This class used for creating the instance of Project.
 *
 * @author Constantin Noga
 */
public class Project {

    private int projectId;
    private String projectName;
    private Calendar projectStartDate;
    private Calendar projectFinishDate;
    private String projectDescription;
    private boolean projectStatus;

    private Map<Integer, User> userList = new HashMap<Integer, User>();
    private List<Iteration> iterationList = new ArrayList<Iteration>();
    private Map<Integer, Meeting> meetingsMap = new HashMap<Integer, Meeting>();
    private List<Task> taskList = new LinkedList<Task>();

    public Project(String projectName, Calendar projectStartDate, Calendar projectFinishDate, String projectDescription) {
        this.projectName = projectName;
        this.projectStartDate = projectStartDate;
        this.projectFinishDate = projectFinishDate;
        this.projectDescription = projectDescription;
        projectStatus = false;
    }

    public int getProjectId() {
        return projectId;
    }

    public void setProjectId(int projectId) {
        this.projectId = projectId;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public Calendar getProjectStartDate() {
        return projectStartDate;
    }

    public void setProjectStartDate(Calendar projectStartDate) {
        this.projectStartDate = projectStartDate;
    }

    public Calendar getProjectFinishDate() {
        return projectFinishDate;
    }

    public void setProjectFinishDate(Calendar projectFinishDate) {
        this.projectFinishDate = projectFinishDate;
    }

    public String getProjectDescription() {
        return projectDescription;
    }

    public void setProjectDescription(String projectDescription) {
        this.projectDescription = projectDescription;
    }

    public Map<Integer, Meeting> getMeetingsMap() {
        return new HashMap<Integer, Meeting>(meetingsMap);
    }

	public List<Task> getTaskList() {
		return new LinkedList<Task>(taskList);
	}

    public List<User> getUserList() {
        return new LinkedList<User>(userList.values());
    }

    public List<Iteration> getIterationList() {
        return new ArrayList<Iteration>(iterationList);
    }

    public void addUser(User user) {
        userList.put(user.getId(), user);
    }

    public void addIteration(Iteration iteration) {
        iterationList.add(iteration);
    }

    public void removeUser(User user) {
        userList.remove(user.getId());
    }

    public boolean addTask(Task task){
        return taskList.add(task);
    }

    public String toString() {
        StringBuilder projectResult = new StringBuilder();
        projectResult.append("Project Id          : ").append(projectId).append("\n");
        projectResult.append("Project Name        : ").append(projectName).append("\n");
        projectResult.append("Project Start Date  : ").append(projectStartDate.getTime()).append("\n");
        projectResult.append("Project Finish Date : ").append(projectFinishDate.getTime()).append("\n");
        projectResult.append("Project Description : ").append(projectDescription).append("\n");
        projectResult.append("Project Status      : ").append((projectStatus ? "Production stage" : "Development stage")).append("\n");

        return projectResult.toString();
    }
}